package jwcb.hire.file.service.controller;

import jwcb.hire.file.service.domain.dto.FileDTO;
import jwcb.hire.file.service.domain.dto.SignDTO;
import jwcb.hire.file.service.domain.vo.FileVO;
import jwcb.hire.file.service.domain.vo.SignVO;
import jwcb.hire.file.service.sercice.IFileService;
import jwcb.hire.common.core.utils.BeanCopyUtil;
import jwcb.hire.common.domain.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping
public class FileController {

    @Autowired
    private IFileService fileService;
    @PostMapping("/upload")
    public R<FileVO> upload(MultipartFile file) {
        FileDTO fileDTO = fileService.upload(file);
        FileVO fileVO = new FileVO();
        BeanCopyUtil.copyProperties(fileDTO, fileVO);
        return R.ok(fileVO);
    }

    @GetMapping("/sign")
    public R<SignVO> getSign() {
        SignDTO signDTO = fileService.getSign();
        SignVO signVO = new SignVO();
        BeanCopyUtil.copyProperties(signDTO, signVO);
        return R.ok(signVO);
    }
}
